﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using AspNetCs.Model;
using AspNetCs.IDAL;
using AspNetCs.DALFactory;
using AspNetCs.SQLServerDAL;
using AspNetCs.Common;

namespace AspNetCs.Bll
{
    public class AncestralHallItemsBLL
    {
        private IAncestralHallItems dal = Conn.CreateAncestralHallItems();


        /// <summary>
        /// 添加宗祠版块
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AncestralHallItems_Model model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 修改宗祠版块
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(AncestralHallItems_Model model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除宗祠版块(物理删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        /// 删除宗祠版块(逻辑删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Hidden(int id)
        {
            return dal.Hidden(id);
        }

        /// <summary>
        /// 删除宗祠版块通过编号(物理删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteById(int id)
        {
            return dal.DeleteById(id);
        }

        /// <summary>
        /// 删除宗祠版块通过编号(逻辑删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int HiddenById(int id)
        {
            return dal.HiddenById(id);
        }


        /// <summary>
        /// 通过宗祠编号查询宗祠版块
        /// </summary>
        /// <param name="CreateId">宗祠编号</param>
        /// <param name="RequeryItems">查询的字段</param>
        /// <param name="IsDel">是否查询的被删除的信息 0:没有删除的 1:删除了的 2:所有的</param>
        /// <returns></returns>
        public DataTable getAncestralHallItemsByAncestralHallId(int id, string RequeryItems, int IsDel)
        {
            return dal.getAncestralHallItemsByAncestralHallId(id,RequeryItems,IsDel);
        }


        public DataTable GetDataTable(string filter)
        {
            return dal.GetDataTable(filter);
        }

        public AncestralHallItems_Model GetModel(string filter)
        {
            DataTable dataTable = new DataTable();
            dataTable = GetDataTable(filter);
            AncestralHallItems_Model model = new AncestralHallItems_Model();
            if (dataTable.Rows.Count > 0)
            {
                model.Id = StringHelper.isNumber_int(dataTable.Rows[0]["id"].ToString());
                model.AncestralHallId = StringHelper.isNumber_int(dataTable.Rows[0]["AncestralHallId"].ToString());
                model.CreateTime = StringHelper.isDatetime(dataTable.Rows[0]["CreateTime"].ToString());
                model.Introduction = dataTable.Rows[0]["Introduction"].ToString();
                model.IsCheck = StringHelper.isNumber_int(dataTable.Rows[0]["IsCheck"].ToString());
                model.IsDel = StringHelper.isNumber_int(dataTable.Rows[0]["IsDel"].ToString());
                model.IsSys = StringHelper.isNumber_int(dataTable.Rows[0]["IsSys"].ToString());
                model.ItemLogo = dataTable.Rows[0]["ItemLogo"].ToString();
                model.ItemName = dataTable.Rows[0]["ItemName"].ToString();
            }
            return model;
        }
    }
}
